import { Component, OnInit, Input } from '@angular/core';
import { PlotService } from '../../plot.service';

@Component({
  selector: 'app-soil-data',
  templateUrl: './soil-data.component.html',
  styleUrls: ['./soil-data.component.scss']
})
export class SoilDataComponent implements OnInit {
  @Input() selectedIndex = 1;
  selectedValue = null
  sortOrder = null
  fixedColumn = true
  public menus = [
    {
      title: "I类用地",// v3
      value: 'c1v1',
      active: false
    },
    {
      title: "II类用地", //v4
      value: 'c2v1',
      active: true
    }
  ]

  public start = 0
  public rows = 200
  public tableData = []

  public theight = 600

  constructor(
    private plotService: PlotService
  ) { }

  ngOnInit() {
    this.getData(this.start, this.rows, 'c2v1')
  }

  getData(start, rows, std) {
    this.plotService.getLandSolid({
      start, rows, std
    }).subscribe((data: any) => {
      if (data && data.results) {
        this.tableData = data.results
      }
    })
  }

  selectedIndexChange(index) {
    let value = this.menus[index].value
    this.getData(this.start, this.rows, value)
  }

  nzSortFnMult(a, b) {
    return a.mult - b.mult
  }

  nzSortFnVal(a, b) {
    return a.val - b.val
  }

}
